package com.ccxe.manage.web.customer;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ccxe.manage.service.CustomerManager;
import com.ccxe.manage.service.UserManager;
import com.ccxe.manage.service.impl.CustomerManagerImpl;
import com.ccxe.manage.service.impl.UserManageImpl;


public class DelServlet extends HttpServlet {

	private CustomerManager cusManage=new  CustomerManagerImpl();
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			doPost(request, response);
	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		 UserManager userManage=new UserManageImpl();
			String key=request.getParameter("key").trim();
			if(key.equals("doDelCus")){
				String cid=request.getParameter("cid");
				if(cid!=null&&!cid.equals("")){
					if(cusManage.deleteCustomer(cid)>0){
						response.sendRedirect(request.getContextPath()+"/servlet/SrhCus");
					}else{
						System.out.println("删除失败!");
						response.sendRedirect(request.getContextPath()+"/servlet/SrhCus");
					}
				}
			}else if(key.equals("doDelUser")){
				String uid=request.getParameter("userID");
				if(uid!=null&&uid.length()>0){
					if(userManage.delUser(uid)>0){
						request.getRequestDispatcher("/servlet/SrhUser").forward(request, response);
					}else{
						request.getRequestDispatcher("/servlet/SrhUser").forward(request, response);
					}
				}
			}
			
		
		
	}

}
